home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / a_man / cat7 / mtio.z / mtio
Encoding:
Text File  |  2002-10-03  |  18.8 KB  |  397 lines

  1.  
  2.  
  3.  
  4. mmmmttttiiiioooo((((7777))))                                                                mmmmttttiiiioooo((((7777))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      mtio - magnetic tape interface
  10.  
  11. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  12.      _m_t_i_o describes the generic interface provided for dealing with the
  13.      various types of magnetic tape drives supported on Silicon Graphics
  14.      systems.  1/4" (QIC) cartridge tapes, 1/2" nine-track tapes, 8 mm video
  15.      tapes, IBM 3590, STK 9490, STK SD3, Sony GY-10 and GY-2120, Ampex DST-
  16.      310, DAT (digital audio tapes), and DLT are currently supported.  (Not
  17.      all systems support all tapedrives.)
  18.  
  19.      Tape drives are accessed through special device files in the /_d_e_v/_m_t/*
  20.      and /_d_e_v/_r_m_t/* directories.  The _m_t directory is a link to the _r_m_t
  21.      directory for ease of porting; the block interface sometimes associated
  22.      with the devices in _m_t is not supported under IRIX.  Refer to _i_n_t_r_o(7)
  23.      for a general description of the naming conventions for device files in
  24.      these subdirectories.  Naming conventions for the specific devices are
  25.      listed under _t_p_s(7M).
  26.  
  27.      Normally the device specific name is linked to a user-friendly synonym
  28.      for ease of use.  Many commands that manipulate magnetic tape refer to
  29.      these synonyms rather than device specific names.  There are up to four
  30.      user-friendly device synonyms:
  31.  
  32.      ////ddddeeeevvvv////ttttaaaappppeeee       This is the tape unit that is the default system tape
  33.                      drive.  It is linked to one of the specific device names
  34.                      in /_d_e_v/_r_m_t.  This device rewinds the tape when closed.
  35.                      For QIC tapes, the devices linked to ////ddddeeeevvvv////ttttaaaappppeeee do
  36.                      software byte swapping to be compatible with the IRIS
  37.                      2000 and 3000 series systems; the non-byte swapping
  38.                      device is also available, and should almost always be
  39.                      used for all tape types other than QIC.
  40.  
  41.      ////ddddeeeevvvv////nnnnrrrrttttaaaappppeeee     Same as ////ddddeeeevvvv////ttttaaaappppeeee, except the tape is not rewound when
  42.                      closed.
  43.  
  44.      ////ddddeeeevvvv////ttttaaaappppeeeennnnssss     Same as ////ddddeeeevvvv////ttttaaaappppeeee, except no byte swapping is done;
  45.                      normally created only for QIC tapes.
  46.  
  47.      ////ddddeeeevvvv////nnnnrrrrttttaaaappppeeeennnnssss   Same as ////ddddeeeevvvv////nnnnrrrrttttaaaappppeeee, except no byte swapping is done;
  48.                      normally created only for QIC tapes.
  49.  
  50.      See the (unfortunately somewhat confusing) script /_d_e_v/_M_A_K_E_D_E_V for
  51.      details of which devices are linked to ////ddddeeeevvvv////ttttaaaappppeeee for each tape type.  In
  52.      particular, look at the ttttaaaappppeeeelllliiiinnnnkkkkssss target for the default links.  Also be
  53.      aware that if a ////ddddeeeevvvv////ttttaaaappppeeee exists as a link to a valid tape device, it is
  54.      left as is, in order to preserve local changes.
  55.  
  56.      Note that even the norewind tape devices can be rewound by the system, in
  57.      some cases.  In particular, all tapes are rewound on first use after a
  58.      system boot, and when detected by the driver, are rewound after the tape
  59.      has been changed.  DAT drives are also rewound when the drive is switched
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. mmmmttttiiiioooo((((7777))))                                                                mmmmttttiiiioooo((((7777))))
  71.  
  72.  
  73.  
  74.      between audio and data modes.  This means that if you wish to append a
  75.      new dataset to a tape that already contains datasets, you should always
  76.      issue the mmmmtttt ffffeeeeoooommmm command AFTER loading the tape, just prior to using the
  77.      program that will append to the tape.  Do not count on a tape remaining
  78.      at EOD, just because that is where it was before it was removed.
  79.  
  80.      The system makes it possible to treat the tape similar to any other file,
  81.      with some restrictions on data alignment and request sizes.  Seeks do not
  82.      have their usual meaning (that is, they are ignored) and it is not
  83.      possible to read or write other than a multiple of the fixed block size
  84.      when using the fixed block device.  Writing in very small blocks (less
  85.      than 4096 bytes) is inadvisable because this tends to consume more tape
  86.      (create large record gaps verses data for 9-track and may pad to a device
  87.      specific boundary for others, such as 8mm, if the drive isn't kept
  88.      streaming); it may also cause the tape to stop its streaming motion,
  89.      increasing wear on the drive and decreasing throughput.
  90.  
  91.      The standard QIC tape consists of a series of 512-byte records terminated
  92.      by an end-of-file.  Other tape devices (such as 9-track, 8 mm, and DAT)
  93.      typically support both fixed size block format and variable size blocks
  94.      format.
  95.  
  96.      When using the variable format, there is an upper limit to the size of a
  97.      single read or write, typically the size of the RAM buffer on the drive.
  98.      At this time, the upper limit is 64K bytes on 9-track and 240K bytes on
  99.      the 8 mm drives.  This information can be obtained by use of the
  100.      MMMMTTTTIIIIOOOOCCCCGGGGEEEETTTTBBBBLLLLKKKKIIIINNNNFFFFOOOO ioctl (for SCSI tape drives only).  The main use of this
  101.      format is to allow small header blocks at the beginning of a tape file,
  102.      while the rest are typically the same (larger) size.
  103.  
  104.      When the fixed block size device is used, the size of a single read or
  105.      write request is limited only by physical memory.  Currently the default
  106.      size is 1024 bytes on 8mm, and 512 bytes for all others.  This size can
  107.      be reset with the MMMMTTTTSSSSCCCCSSSSIIII____SSSSEEEETTTTFFFFIIIIXXXXEEEEDDDD ioctl or the mmmmtttt sssseeeettttbbbbllllkkkksssszzzz XXXXXXXXXXXX command;
  108.      the value remains set until the next boot or reset via ioctl.  If the
  109.      variable blocksize device is used, the block size reverts to the default
  110.      on the next use of the fixed blocksize device.  The default fixed
  111.      blocksize for the _t_p_s driver is set from the table in the
  112.      /_v_a_r/_s_y_s_g_e_n/_m_a_s_t_e_r._d/_s_c_s_i file, as are the drive types, based on the
  113.      inquiry data returned by the drive.
  114.  
  115.      A tape is normally open for reading and/or writing, but a tape cannot be
  116.      read and written simultaneously.  After a rewind, a space, an unload, or
  117.      an MMMMTTTTAAAAFFFFIIIILLLLEEEE ioctl, writes can follow reads and vice-versa, otherwise only
  118.      reads, or only writes can be done unless the tape is first closed;
  119.      performing an MMMMTTTTWWWWEEEEOOOOFFFF ioctl is considered to be a write operation in this
  120.      sense; after reading, an MMMMTTTTWWWWEEEEOOOOFFFF is not allowed unless one of the
  121.      operations above is first executed, or the tapedrive is closed and
  122.      reopened.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. mmmmttttiiiioooo((((7777))))                                                                mmmmttttiiiioooo((((7777))))
  137.  
  138.  
  139.  
  140.      Whenever the tape is closed after being written to, a file-mark is
  141.      written (2 on 9-track tapes) unless the tape has been unloaded or rewound
  142.      just prior to the close; if the last operation before the close is an
  143.      MMMMTTTTWWWWEEEEOOOOFFFF, no additional filemarks are written at close.
  144.  
  145.      Some tape drives support more than one speed; for SCSI 9-track tape
  146.      drives, the default is 100 ips (streaming mode); this can be set to 50
  147.      ips by using the MMMMTTTTSSSSCCCCSSSSIIII____SSSSPPPPEEEEEEEEDDDD ioctl.  Some tape drives such as the
  148.      Kennedy 96XX models do auto density select when reading; this can be
  149.      disabled only by using the drive's front panel setup mode.
  150.  
  151.      The MMMMTTTTSSSSCCCCSSSSIIIIIIIINNNNQQQQ ioctl returns the inquiry data for SCSI tape drives.  The
  152.      buffer supplied in the 3rd argument must be at least MMMMTTTTSSSSCCCCSSSSIIII____IIIINNNNQQQQUUUUIIIIRRRRYYYY____LLLLEEEENNNN
  153.      bytes long.  It returns all the information returned by the inquiry
  154.      command, with the identification string starting at offset 8 in the
  155.      buffer.
  156.  
  157.      The MMMMTTTTSSSSCCCCSSSSIIII____SSSSEEEENNNNSSSSEEEE ioctl returns the most recent request sense data for
  158.      SCSI tape drives.  The buffer must be at least MTSCSI_SENSE_LEN long,
  159.      although less data may be returned.  The data is from the most recent
  160.      request sense SCSI command issued, and may not be directly related to the
  161.      most recent system call to the tape driver, since at open, and for some
  162.      ioctl's, multiple SCSI commands are issued.  The buffer is never cleared.
  163.      The data is as returned by the tape drive, and the returned data must be
  164.      examined to return the valid length.  Currently at most 64 bytes will be
  165.      returned, but callers must not assume this will remain true in the
  166.      future.
  167.  
  168.      The MMMMTTTTAAAANNNNSSSSIIII ioctl allows writing of ANSI 3.27 style labels after the early
  169.      warning point (naturally, drives that don't support variable sized blocks
  170.      won't support 80 byte labels).  It is currently implemented only for SCSI
  171.      tape drives.  It remains set until the next close, or reset with a 0
  172.      argument.  If used, standard Silicon Graphics EOT handling for _t_a_r, _b_r_u,
  173.      and _c_p_i_o won't work correctly while set.  An arg of 1 enables, 0
  174.      disables.  NOTE: When the EOT marker is encountered, the current I/O
  175.      operation returns either a short count (if any I/O completed), or -1 (if
  176.      no I/O completed); it is the programmers responsibility to determine if
  177.      EOT has been encountered by using MMMMTTTTIIIIOOOOCCCCGGGGEEEETTTT or logic internal to the
  178.      program.  This ioctl should be issued AFTER encountering EOT, if ANSI
  179.      3.27 EOT handling is desired.  Subsequent I/Os are then allowed and
  180.      return the count actually transferred or -1 if the drive was unable to
  181.      transfer any data.  The standard calls for writing a FM before the label.
  182.      If this is not done, the drive may return label info as data.
  183.  
  184.      The MMMMTTTTBBBBUUUUFFFFFFFFMMMMMMMMOOOODDDDEEEE ioctl can be used to enable/disable the writing of
  185.      buffered filemarks. An arg of 1 enables, 0 disables. Normally, commands
  186.      which result in the writing of filemarks will not complete until write
  187.      data and subsequent filemarks are actually written to tape. By enabling
  188.      buffered filemark writing, on those devices which support it, one can
  189.      achieve higher performance.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. mmmmttttiiiioooo((((7777))))                                                                mmmmttttiiiioooo((((7777))))
  203.  
  204.  
  205.  
  206.      The MMMMTTTTGGGGEEEETTTTAAAATTTTTTTTRRRR ioctl can be used to obtain functional attributes of a tape
  207.      device. The arg will be a pointer to an instance of the structure
  208.      mt_attr. (See /usr/include/sys/mtio.h) The attribute whose value is to be
  209.      determined must be specified in ma_name, space for the return value must
  210.      be allocated, and a pointer to it and its size must be specified in
  211.      ma_value and ma_vlen respectively. Currently available attributes are
  212.  
  213.      _M_T__A_T_T_R__N_A_M_E__R_E_W_I_N_D
  214.           MT_ATTR_VALUE_TRUE or MT_ATTR_VALUE_FALSE is returned depending on
  215.           whether the device is a rewind-on-close device.
  216.  
  217.      _M_T__A_T_T_R__N_A_M_E__V_A_R_I_A_B_L_E
  218.           MT_ATTR_VALUE_TRUE or MT_ATTR_VALUE_FALSE is returned depending on
  219.           whether the device is a variable block device.
  220.  
  221.      _M_T__A_T_T_R__N_A_M_E__S_W_A_P
  222.           MT_ATTR_VALUE_TRUE or MT_ATTR_VALUE_FALSE is returned depending on
  223.           whether the device is a swap device.
  224.  
  225.      _M_T__A_T_T_R__N_A_M_E__C_O_M_P_R_E_S_S__D_E_N_S
  226.           For devices which don't support multiple densities but do support a
  227.           compression mode, "compress" or "uncompress" is returned depending
  228.           on whether the device is a compression device. For devices which do
  229.           support multiple densities, the device specific density/compression
  230.           value is returned.
  231.  
  232.      _M_T__A_T_T_R__N_A_M_E__D_E_V_S_C_S_I
  233.           The full pathname of the associated devscsi device is returned.
  234.  
  235.      The MMMMTTTTFFFFPPPPMMMMEEEESSSSSSSSAAAAGGGGEEEE ioctl can be used to display an ASCII message on the
  236.      device's diagnostic panel, if the device supports such a feature. The arg
  237.      will be a pointer to an instance of the structure mt_fpmsg. (See
  238.      /usr/include/sys/mtio.h) The ASCII message and it's length will be
  239.      specified in mm_msg and mm_mlen respectively.
  240.  
  241.      Tape devices with multiple initiators may have a persistent reservation
  242.      placed on them with the MMMMTTTTRRRRSSSSVVVV op code of the MMMMTTTTIIIIOOOOCCCCTTTTOOOOPPPP ioctl.  If another
  243.      system has already placed a reservation against this device, the ioctl
  244.      will return EBUSY. The reservation may be cleared with the MMMMTTTTRRRRLLLLSSSS op code
  245.      of the MMMMTTTTIIIIOOOOCCCCTTTTOOOOPPPP ioctl.  Both the MMMMTTTTRRRRSSSSVVVV and MMMMTTTTRRRRLLLLSSSS operations are
  246.      restricted to users with CCCCAAAAPPPP____DDDDEEEEVVVVIIIICCCCEEEE____MMMMGGGGTTTT capability.
  247.  
  248.      Two flags, returned in the mt_dposn field of the mtget struct after a
  249.      call to MMMMTTTTIIIIOOOOCCCCGGGGEEEETTTT,,,, are provided for the purpose of determining whether a
  250.      logical-end-of-tape (LEOT, encountered at the early-warning point) or a
  251.      physical-end-of-tape (PEOT) has been encountered; MT_EW and MT_EOT. With
  252.      MTANSI reset, writing is permitted from BOT to LEOT at which point both
  253.      MT_EW and MT_EOT and set. If MTANSI is now set, MT_EOT is reset (MT_EW
  254.      remains set) and writing is permitted until PEOT is encountered, at which
  255.      point MT_EOT is again set and remains set until the tape is repositioned
  256.      backward.
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. mmmmttttiiiioooo((((7777))))                                                                mmmmttttiiiioooo((((7777))))
  269.  
  270.  
  271.  
  272. IIIIOOOOCCCCTTTTLLLL OOOOPPPPEEEERRRRAAAATTTTIIIIOOOONNNNSSSS
  273.      Different drivers and drives support different tape commands, in the form
  274.      of ioctl's.  These operations and their structures are defined in the
  275.      file /_u_s_r/_i_n_c_l_u_d_e/_s_y_s/_m_t_i_o._h, which has fairly extensive comments.  All
  276.      drivers support some common definitions of tape status via the MMMMTTTTIIIIOOOOCCCCGGGGEEEETTTT
  277.      ioctl; in particular, the bits defined for the _m_t__d_p_o_s_n field of the
  278.      _m_t_g_e_t structure are the same for all the IRIX devices.  other fields are
  279.      driver specific, and the appropriate header files should be consulted for
  280.      the meaning of these fields.
  281.  
  282.      Those ioctls that are not supported for a particular drive or driver
  283.      normally return EINVAL.  For example, the MMMMTTTTAAAAFFFFIIIILLLLEEEE ioctl returns EINVAL if
  284.      the tape drive is not a device that supports overwrite (currently only
  285.      9-track and DAT), since QIC and 8mm drives only allow appending at EOD
  286.      and, for 8mm, from the BOT side of a FM.
  287.  
  288. NNNNOOOOTTTTEEEESSSS
  289.      When a tape device is opened, the tape is rewound if there has been a
  290.      media change, or the drive has gone offline, or there has been a bus
  291.      reset (normally only after a reboot or powerup); otherwise the tape
  292.      remains at the same position as at the previous close.  See the specific
  293.      driver manual pages for more details.
  294.  
  295. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  296.      The following code fragment opens the default no rewind tape device,
  297.      positions it to the 2nd filemark, and then rewinds it.  This is typical
  298.      of the use of most of the op codes for the MMMMTTTTIIIIOOOOCCCCTTTTOOOOPPPP and AAAABBBBIIII____MMMMTTTTIIIIOOOOCCCCTTTTOOOOPPPP
  299.      ioctls; the latter is for use by programs compliant with the MIPS ABI
  300.      and, other than the name, functions identically to the former.
  301.  
  302.           #include <sys/types.h>
  303.           #include <sys/mtio.h>
  304.           main()
  305.           {
  306.                struct mtop op;
  307.                int fd;
  308.  
  309.                if((fd = open("/dev/nrtape", 0)) == -1)
  310.                     perror("can't open /dev/tape");
  311.  
  312.                op.mt_op = MTFSF;
  313.                op.mt_count = 2; /* number of fmk's to skip */
  314.                if(ioctl(fd, MTIOCTOP, &op) == -1)
  315.                     perror("ioctl to skip 2 FMs fails");
  316.  
  317.                op.mt_op = MTREW; /* mt_count field is ignored for MTREW */
  318.                if(ioctl(fd, MTIOCTOP, &op) == -1)
  319.                     perror("ioctl to rewind fails");
  320.           }
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. mmmmttttiiiioooo((((7777))))                                                                mmmmttttiiiioooo((((7777))))
  335.  
  336.  
  337.  
  338. FFFFIIIILLLLEEEESSSS
  339.      /dev/tape
  340.      /dev/nrtape
  341.      /dev/tapens
  342.      /dev/nrtapens
  343.      /dev/rmt/*
  344.  
  345. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  346.      MAKEDEV(1M), bru(1), cpio(1), mt(1), tar(1), dataudio(3), rmtops(3),
  347.      datframe(4), tps(7M).
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.